package com.ld.control.business.process.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ld.control.business.process.mapper.ProcessNodeExampleRunningParamMapper;
import com.ld.control.business.process.model.ProcessNodeExampleRunningParamModel;
import com.ld.control.business.process.service.ProcessNodeExampleRunningParamService;
import com.ld.control.business.process.vo.req.ProcessNodeExampleRunningParamReqVo;
import com.ld.control.business.process.vo.req.UpdateNodeParamReqVo;
import com.ld.control.business.process.vo.resp.ProcessNodeExampleRunningParamRespVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * <p>
 * 任务节点指令发送信息表 服务实现类
 * </p>
 *
 * @author wangfeng
 * @since 2024-05-27
 */
@Service
public class ProcessNodeExampleRunningParamServiceImpl extends ServiceImpl<ProcessNodeExampleRunningParamMapper, ProcessNodeExampleRunningParamModel> implements ProcessNodeExampleRunningParamService {

    @Autowired
    private ProcessNodeExampleRunningParamMapper processNodeExampleRunningParamMapper;

    @Override
    public List<ProcessNodeExampleRunningParamRespVo> getListByRunningId(Long processNodeExampleRunningId) {
        return processNodeExampleRunningParamMapper.selectListByRunningId(processNodeExampleRunningId);
    }

    @Override
    public void batchUpdate(UpdateNodeParamReqVo reqVo) {
        List<ProcessNodeExampleRunningParamReqVo> processNodeExampleRunningParamReqVoList = reqVo.getProcessNodeExampleRunningParamReqVoList();
        if (!CollectionUtils.isEmpty(processNodeExampleRunningParamReqVoList)){
            ProcessNodeExampleRunningParamModel processNodeExampleRunningParamModel;
            for (ProcessNodeExampleRunningParamReqVo data : processNodeExampleRunningParamReqVoList) {
                processNodeExampleRunningParamModel = new ProcessNodeExampleRunningParamModel();
                BeanUtils.copyProperties(data, processNodeExampleRunningParamModel);
                processNodeExampleRunningParamMapper.updateById(processNodeExampleRunningParamModel);
            }
        }
    }
}
